﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace MultipleBooking
{
    public static class ProgressBar
    {
        public static int ProgressBarWidth = 40;
        public static int Max = 100;
        public static int BookingsComplete;
        public static int BookingsTotal;
        public static Stopwatch Clock;
        private static int value = 0;
        public static int A;
        public static int B;
        public static int C;
        public static int D;
        public static void TickValue()
        {
            value++;
            SetValue(value);
        }
        public static void SetValue(int val)
        {
            value = val;
            //Console.Write(string.Empty.PadRight(ProgressBarWidth, '\b'));
            Console.CursorLeft = 0;

            float perc = val / (float)Max * 100;
            if (perc > 100) perc = 100;
            int width = (int)(perc * ProgressBarWidth / 100);
            int left = ProgressBarWidth - width;

            BookingsComplete = val;
            BookingsTotal = Max;

            string output = string.Format(
                "[ {0}{1} ] {2}% {3} {4} {5}",
                string.Empty.PadLeft(width, '='),
                string.Empty.PadLeft(left, ' '),
                perc.ToString("0.0") + " ", 
                string.Format("{0}/{1}", BookingsComplete, BookingsTotal), 
                string.Format("{0} b/s", (BookingsComplete / Clock.Elapsed.TotalSeconds).ToString("00.00")), 
                string.Format("[{0}, {1}, {2}, {3}]", A, B, C, D));

            Console.Write(output);
        }
    }
}
